package com.fjrcloud.controller;

import com.fjrcloud.entity.*;
import com.fjrcloud.exception.BusinessException;
import com.fjrcloud.service.HouseholdService;
import com.fjrcloud.service.OtherAppendagesService;
import com.fjrcloud.utils.StatusUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by shengjian.lin on 17-2-20.
 */
@Controller
@RequestMapping("api/housing")
public class OtherAppendagesController {

    @Autowired
    private HouseholdService householdService;
    @Autowired
    private OtherAppendagesService service;


    @RequestMapping("appendages/save")
    @ResponseBody
    public ResponseBean saveAppendages(Appendages appendages,Integer masterId) throws BusinessException {
        return ResponseFactory.getResponseBean(StatusUtils.Success,service.saveAppendages(appendages,masterId));
    }
    @RequestMapping("appendages/get")
    @ResponseBody
    public ResponseBean getAppendages(Integer id){
        return ResponseFactory.getResponseBean(StatusUtils.Success,service.getAppendages(id));
    }
    @RequestMapping("appendages/del")
    @ResponseBody
    public ResponseBean delAppendages(Integer id){
        service.delAppendages(id);
        return ResponseFactory.getResponseBean(StatusUtils.Success);
    }
    @RequestMapping("appendages/find")
    @ResponseBody
    public ResponseBean findAppendages(Integer masterId,Integer pageNum, Integer pageSize) throws BusinessException {
        return ResponseFactory.getResponseBean(StatusUtils.Success,service.findAppendages(masterId,pageNum,pageSize));
    }


    @RequestMapping("subsidies/save")
    @ResponseBody
    public ResponseBean saveSubsidies(SubsidiesOldMan subsidies,Integer masterId) throws BusinessException {
        return ResponseFactory.getResponseBean(StatusUtils.Success,service.saveSubsidiesOldMan(subsidies,masterId));
    }
    @RequestMapping("subsidies/get")
    @ResponseBody
    public ResponseBean getSubsidies(Integer id){
        return ResponseFactory.getResponseBean(StatusUtils.Success,service.getSubsidiesOldMan(id));
    }
    @RequestMapping("subsidies/del")
    @ResponseBody
    public ResponseBean delSubsidies(Integer id){
        service.getSubsidiesOldMan(id);
        return ResponseFactory.getResponseBean(StatusUtils.Success);
    }
    @RequestMapping("subsidies/find")
    @ResponseBody
    public ResponseBean findSubsidies(Integer masterId,Integer pageNum, Integer pageSize) throws BusinessException {
        return ResponseFactory.getResponseBean(StatusUtils.Success,service.findSubsidiesOldMan(masterId,pageNum,pageSize));
    }
}

